import type { Department } from './model';

import type { ID, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  departmentDelete = '/department/v1/deleteHospitalDepart',
  departmentList = '/department/v1/pageList',
  departmentSave = '/department/v1/saveHospitalDepart',
  departmentUpdate = '/department/v1/updateHospitalDepart',
}

/**
 * 科室分页列表
 * @param data 请求参数
 * @returns 列表
 */
export function departmentList(data?: any) {
  return requestClient.post<PageResult<Department>>(Api.departmentList, data);
}

/**
 * 新增科室
 * @param data 参数
 */
export function departmentAdd(data: Partial<Department>) {
  return requestClient.postWithMsg<void>(Api.departmentSave, data);
}

/**
 * 更新科室
 * @param data 参数
 */
export function departmentUpdate(data: Partial<Department>) {
  return requestClient.postWithMsg<void>(Api.departmentUpdate, data);
}

/**
 * 删除科室
 * @param departmentId 科室ID
 */
export function departmentRemove(departmentId: ID) {
  return requestClient.get<void>(`${Api.departmentDelete}?id=${departmentId}`);
}
